package org.dant.ant.extension.net.processors;

import org.dant.ant.extension.net.Processor;

import org.dant.ant.extension.tasks.internal.RemoteCommand;
import org.dant.ant.extension.tasks.internal.RemoteResponse;
import org.dant.ant.extension.tasks.commands.CommandsConstants;

public class PingProcessor implements Processor {

  public void process(RemoteCommand req, RemoteResponse response) {
    System.out.println("ping from: " + req.getSourceHost() + " echo: " + req.getParameter("echo"));    
    response.setCommandType(req.getName());
    if (CommandsConstants.DANT_CMD_PING.equals(req.getName())) {
      response.setResult((String)req.getParameter("echo"));
    } else {
      response.setSuccess(false);
      response.setResult("Required a PING command , but is not a PING command");
    }
  }
}
